package com.star.percalservice.controller;

import com.star.percalservice.model.dto.TeacherDTO;
import com.star.percalservice.model.entity.Teacher;
import com.star.percalservice.service.TeacherService;
import com.star.percalservice.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author star
 * @version 1.0
 * @Description:
 * @DateTime 2025/4/13 2:45
 */
@RestController
@RequestMapping("/api/teacher")
public class TeachController {

    @Autowired
    private TeacherService teacherService;

    @GetMapping("/data-id")
    public R getTeacherDataById(Integer id) {
        return teacherService.getTeacherDataById(id);
    }

    @GetMapping("/getByUserId")
    public R getByUserId(@RequestParam("userId") Integer userId) {
        return teacherService.getByUserId(userId);
    }

    @PostMapping("/list")
    public R list(@RequestBody TeacherDTO teacherDTO) {
        return teacherService.list(teacherDTO);
    }

    @PostMapping("/add")
    public R add(@RequestBody Teacher teacher) {
        return teacherService.add(teacher);
    }

    @PostMapping("/update")
    public R update(@RequestBody Teacher teacher) {
        return teacherService.update(teacher);
    }

    @PostMapping("/delete")
    public R delete(Integer id) {
        return teacherService.delete(id);
    }





}
